import 'package:flutter_bilibili/core/model/live_rooms_model.dart';
import 'package:flutter_bilibili/core/model/live_room_stream_model.dart';

import '../../model/info_by_live_room_model.dart';
import '../../model/online_gold_rank_model.dart';
import '../utils/http_request.dart';

class HYLiveRoomPlayRequest {
  static Future<HYLiveRoomStreamModel> getLiveRoomStreamData(int cid) async {
    final url = "/Room/playUrl?cid=${cid}";
    final result = await HttpBaseRequest.request("live", url);
    final liveRoomStreamJson = result["data"];
    return HYLiveRoomStreamModel.fromJson(liveRoomStreamJson);
  }

  static Future<HYInfoByLiveRoomModel> getInfoByLiveRoomData(int roomId) async {
    final url = "/web-room/v1/index/getInfoByRoom?room_id=${roomId}";
    final result = await HttpBaseRequest.request("xlive", url);
    final infoByLiveRoomModelJson = result["data"];
    return HYInfoByLiveRoomModel.fromJson(infoByLiveRoomModelJson);
  }

  static Future<HYOnlineGoldRankModel> getOnlineGoldRankData(
      int ruId, int roomId, int page, int pageSize) async {
    final url =
        "/general-interface/v1/rank/getOnlineGoldRank?ruid=${ruId}&roomId=${roomId}&page=${page}&pageSize=${pageSize}";
    print(url);
    final result = await HttpBaseRequest.request("xlive", url);
    final infoByLiveRoomModelJson = result["data"];
    return HYOnlineGoldRankModel.fromJson(infoByLiveRoomModelJson);
  }
}
